﻿using System;
using System.Collections.Generic;

namespace Sustainalytics.Caching
{
    /// <summary>
    /// Cache.
    /// </summary>
    public interface IAppCache
    {
        /// <summary>
        /// Add new cache item.
        /// </summary>
        /// <param name="key"> Cache item key. </param>
        /// <param name="value"> Cache item value. </param>
        void Set(string key, string value);

        void Set(string key, IEnumerable<string> value);


        /// <summary>
        ///  adds values to a existing set or creates a new set with this value
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        void Add2Set(string key, string value);

        /// <summary>
        /// Get cache item from cache.
        /// </summary>
        /// <param name="key"> Cache item key. </param>
        /// <returns> Cache item value as string. </returns>
        string GetString(string key);

        IEnumerable<string> GetSet(string key);

        /// <summary>
        /// Remove item from cache.
        /// </summary>
        /// <param name="key"> Cache item key. </param>
        void Remove(string key);

        /// <summary>
        /// Remove item inside a set from cache.
        /// </summary>
        /// <param name="key"> Cache item key. </param>
        /// <param name="value"> Cache item value. </param>
        void Remove(string key, string value);

        /// <summary>
        /// Clear all items.
        /// </summary>
        void Clear();

        /// <summary>
        /// Subscribe to cache items changes.
        /// </summary>
        /// <param name="action"> Action receiving the specific cache change. </param>
        void Subscribe(Action<AppCacheItemAction> action);

        void CloseAll();
    }
}
